﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../assets/css/plugins/footable/footable.core.css" rel="stylesheet">
    <link href="../assets/css/shelf/base.css" rel="stylesheet">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="system-box">
        <div class="right-side">
            <div class="btns-container"></div>
            <div class="condition">
                <label>搜索关键字</label>
                <input id="keys" class="form-control input-w160" placeholder="店铺编号或名称" />
                <label>季节</label>
                <select id="search-season" class="form-control input-w160">
                    <option value="">所有</option>
                </select>
                <label>陈列类别</label>
                <select id="search-category" class="form-control input-w160">
                    <option value="">所有</option>
                    <option value="服装">服装</option>
                    <option value="鞋">鞋</option>
                </select>
                <label>年份</label>
                <select id="search-year" class="form-control input-w160">
                    <option value="">所有</option>
                </select>
            </div>
            <div class="right-content-box">
                <div class="ibox-content">
                    <table class="footable table table-stripped">
                        <thead></thead>
                        <tbody id="pageList"></tbody>
                    </table>
                </div>
            </div>

            <div class="pageControl"></div>

        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
    <script src="../assets/js/page/pageControl.js"></script>
    <script src="../assets/js/page/rScroll.js"></script>
    <script src="../assets/js/page/tableControl.js"></script>
    <script src="../assets/js/framework.js"></script>
    <script type="application/javascript">
        $(document).ready(function () {
            //自动收缩左边菜单栏
            commonUtil.autoLeftWidth();
            //模块ID
            var ModuleID = Y.getUrlParam("ModuleID");
            //用于记录页数
            var page = 1;
            //用于记录每页多少条记录
            var size = 10;
            //用于记录各项信息
            var pageList = [];

            commonUtil.loadBtnList(ModuleID, function () {
                rScroll();
            });

            //绑定年份
            commonUtil.bindDict({ DictValue: 'year' }, ['#search-year']);

            //绑定季节
            commonUtil.bindDict({ DictValue: 'season' }, ['#search-season']);

            //计算陈列容量
            var CalcSkcCapacity = function (category, skc) {
                var result = 0;
                switch (category) {
                    case "服装":
                        result = skc * 7;
                        break;
                    case "鞋":
                        result = skc * 5;
                        break;
                    default:
                        result = 0;
                        break;
                }
                return result;
            }

            //加载信息列表
            var loadList = function () {
                if ($('.footable thead').children().size() == 0)
                    tableControl.initThead2('.footable', ['年份', '季节', '店铺编号', '店铺名称', '陈列类别', '零售区域', '商品区域', '最高陈列SKC', '标准陈列SKC', '最低陈列SKC', '最高陈列容量', '标准陈列容量', '最低陈列容量']);

                $('.detail-box').fadeOut();
                pageControl.init('ShopSKC', 'GetList', {
                    Keys: $('#keys').val(),
                    Category: $('#search-category').val(),
                    Year: $('#search-year').val(),
                    Season: $('#search-season').val(),
                    Page: page,
                    //          Size: size,
                }, function (result) {
                    page = result.page;
                    var tBody = [];
                    if (!Y.checkNull(result.data)) {
                        if (result.data.Items.length > 0) {
                            result.data.Items.map(function (item, i) {
                                var tempTr = {
                                    trClass: (i % 2 == 0 ? 'gradeX footable-even' : 'gradeX footable-odd'),
                                    children: [
                                        { tdText: (item.Year || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (item.Season || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (item.ShopCode || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (item.ShopName || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (item.Category || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (item.OperationAreaName || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (item.ParentAreaName || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (item.ASKC || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (item.BSKC || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (item.CSKC || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (CalcSkcCapacity(item.Category, item.ASKC) || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (CalcSkcCapacity(item.Category, item.BSKC) || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                        { tdText: (CalcSkcCapacity(item.Category, item.CSKC) || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    ]
                                };
                                tBody.push(tempTr);
                            })
                        }
                        rScroll();
                        pageList = [];
                        pageList = result.data.Items;
                    }
                    tableControl.initTbody('.footable', (tBody.length > 0 ? tBody : null), 8, null);
                });
            }
            loadList();

            //查询按钮
            $('.btns-container').on('click', '#btn-search', function () {
                page = 1;
                loadList();
            });

            //导出
            $(document).on("click", "#exportBtn", function () {
                var conditionsArr = [];
                var keys = $("#keys").val();
                var season = $("#search-season").val();
                var category = $("#search-category").val();
                var year = $("#search-year").val();
                if (!Y.checkNull(keys)) {
                    conditionsArr.push({ connector: "and", column: "shopcode", operator: "like", value: keys, });
                    conditionsArr.push({ connector: "or", column: "shopname", operator: "like", value: keys });
                }
                if (!Y.checkNull(year)) {
                    conditionsArr.push({ connector: "and", column: "Year", operator: "=", value: year });
                }
                if (!Y.checkNull(season)) {
                    conditionsArr.push({ connector: "and", column: "Season", operator: "=", value: season });
                }
                if (!Y.checkNull(category)) {
                    conditionsArr.push({ connector: "and", column: "Category", operator: "=", value: category });
                }

                conditionsArr = JSON.stringify(conditionsArr);
                var tempParam = {};
                tempParam.filename = "店铺陈列SKC";
                tempParam.filetype = "SHOPSKCEXCEL";
                tempParam.conditions = encodeURIComponent(conditionsArr);
                var t = $.Export(tempParam);
            });

        });
    </script>
</asp:Content>

